/****   http.js   ****/
// 导入封装好的请求实例
import request from "./request"

const http = {
	/**
	 * methods: 请求
	 * @param url 请求地址 
	 * @param params 请求参数
	 */
	get(url, params) {
		const config = {
			url: url,
			method: 'get',
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}
		if (params) config.data = params;
		return request(config)
	},
	post(url, params) {
		const config = {
			url: url,
			method: 'post',
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}
		if (params) config.data = params;
		return request(config)
	},
	put(url, params) {
		const config = {
			url: url,
			method: 'put',
			header: {
				'Content-Type': 'multipart/form-data'
			}
		}
		if (params) config.data = params;
		return request(config)
	},
	delete(url, params) {
		const config = {
			url: url,
			method: 'delete',
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}
		if (params) config.data = params;
		return request(config)
	}
}
//导出
export default http
